package org.jxf.gps.jt808.server;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import org.apache.log4j.Logger;
import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jxf.gps.jt808.message.JT808FrameDecoder;
import org.jxf.gps.jt808.message.ShowLogFrameDecoder;
import org.jxf.gps.jt808.nettysample.test.UDPChannelPipelineFactory;

import com.jfinal.plugin.IPlugin;

public class UDPServerPlugin implements IPlugin {
	private static Logger logger = Logger.getLogger(UDPServerPlugin.class);

	public boolean start() {
		logger.info("UDPServerPlugin start !!!");
		
    	ConnectionlessBootstrap  bootstrap;
        bootstrap=new ConnectionlessBootstrap(new NioDatagramChannelFactory(Executors.newCachedThreadPool()));
        bootstrap.setPipelineFactory(new UDPChannelPipelineFactory());
        bootstrap.bind(new InetSocketAddress(59090));
		
		
		return true;
	}

	public boolean stop() {
		logger.info("ServerPlugin stop !!!");
		return true;
	}

}
